Micron Document
🎖️GitЯра🎖️

Node / meshtastic / Meshtastic-Android / files / androidApp / src / google / kotlin / org / meshtastic / app / map / MapsSdkInitializer.kt

Displaying Raw • Download

androidApp/src/google/kotlin/org/meshtastic/app/map/MapsSdkInitializer.kt 0f123adb72d3d13a208959a17f7d9dd40809804b (0f123adb) Text, 3.08 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.app.map

Tff7b72import T7ee787android.content.Context
Tff7b72import T7ee787co.touchlab.kermit.Logger
Tff7b72import T7ee787com.google.android.gms.maps.MapsInitializer
Tff7b72import T7ee787java.util.concurrent.atomic.AtomicBoolean

T8b949e/**
* Centralized, run-once Google Maps SDK initialization for the google flavor.
*
* Two things happen here, deliberately decoupled:
* 1. **Synchronous init** via the single-arg [MapsInitializer.initialize] overload. This is the only overload
* documented as synchronous, and it guarantees `BitmapDescriptorFactory` is ready before any eager Canvas descriptor
* is built off a live `GoogleMap` (the node-detail inline map builds its icon before its map loads — see #5709 and
* `MarkerBitmapRenderer`). It is idempotent, so repeated calls are no-ops.
* 2. **Renderer reporting** via the callback overload, registered exactly once. We can no longer *force* a renderer
* (the LEGACY renderer was decommissioned in March 2025, so a preference is honored only as a hint), but the
* documented "Latest renderer" tile-rendering failures can still leave the base map blank on some devices. Logging
* which renderer actually loaded lets us correlate "black map" field reports in Crashlytics/Datadog. Kermit's
* [Logger] is the sink because `GooglePlatformAnalytics` wires its Crashlytics/Datadog log writers at startup while
* delaying SDK init until consent — so logging through Kermit is the privacy-correct, already-sanctioned path (vs.
* touching `Firebase.crashlytics` directly).
*/
Tff7b72object T56d364MapsSdkInitializer Tb4b4b4{

Tff7b72private Tff7b72val Te6edf3callbackRegistered Tff7b72= Te6edf3AtomicBooleanTb4b4b4(Tff7b72falseTb4b4b4)

Tff7b72fun Td2a8ffensureInitializedTb4b4b4(Te6edf3contextTb4b4b4: Te6edf3ContextTb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3app Tff7b72= Te6edf3contextTb4b4b4.Te6edf3applicationContext

T8b949e// (1) Synchronous readiness guarantee — see kdoc. Deprecated overload retained intentionally.
Tf0883e@SuppressTb4b4b4(Ta5d6ff"Ta5d6ffDEPRECATIONTa5d6ff"Tb4b4b4)
Te6edf3MapsInitializerTb4b4b4.Te6edf3initializeTb4b4b4(Te6edf3appTb4b4b4)

T8b949e// (2) Register the renderer-reporting callback once. The SDK is already initialized above, so the
T8b949e// callback fires promptly with the renderer that actually loaded.
Tff7b72if Tb4b4b4(Te6edf3callbackRegisteredTb4b4b4.Te6edf3compareAndSetTb4b4b4(Tff7b72falseTb4b4b4, Tff7b72trueTb4b4b4)Tb4b4b4) Tb4b4b4{
Te6edf3MapsInitializerTb4b4b4.Te6edf3initializeTb4b4b4(Te6edf3appTb4b4b4, Te6edf3MapsInitializerTb4b4b4.Te6edf3RendererTb4b4b4.Te6edf3LATESTTb4b4b4) Tb4b4b4{ Te6edf3renderer Tff7b72-Tff7b72>
Te6edf3LoggerTb4b4b4.Te6edf3withTagTb4b4b4(Te6edf3TAGTb4b4b4)Tb4b4b4.Te6edf3i Tb4b4b4{ Ta5d6ff"Ta5d6ffGoogle Maps renderer loaded: Tffd700$Te6edf3rendererTa5d6ff" Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}

Tff7b72private Tff7b72const Tff7b72val Te6edf3TAG Tff7b72= Ta5d6ff"Ta5d6ffMapsSdkInitializerTa5d6ff"
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.04s